<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   design_blank
 * @package    Mage
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/**
 * Product description template
 *
 * @see Mage_Catalog_Block_Product_View_Description
 */
?>
<?php if( $this->isBundlepromotion() ):?>
<div class="bundled-promotions">
	<div class="title-block"><div class="title-bg-end"><h3><?php echo $this->__('Frequently Bought Together Discount') ?></h3></div></div>
	<div class="block-content">
	<?php $bundled_promotions_collection = $this->getBundledPromotion();?>
	<?php $promotion_counter = 1;?>
	<?php foreach(  $bundled_promotions_collection  as $bundled_promotion ):?>
		<form name="bundled-promotion-<?php echo $promotion_counter;?>" action="<?php echo $this->getUrl("checkout/cart/addcombine");?>" method="post">
		<input type="hidden" name="coupon_code" value="<?php echo $bundled_promotion->getData('coupon_code');?>">
		<table class="products-grid" id="products-grid-table">
			<tbody>
				<tr>
					<td>
					
					<?php $collection = $bundled_promotion->getProductCollection();?>
					<?php $counter = 0;?>
					<?php $price_total = 0;?>
					<?php foreach( $collection as $_product ):?>
						<div class="product-image <?php if( $counter + 1 == $collection->getSize() ) echo 'last'?>  <?php if( $counter ) echo 'and';?>">
							<a class="link" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'thumbnail')) ?>">
								<img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(70, 100); ?>" width="70" height="100" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'thumbnail')) ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'thumbnail')) ?>" />
							</a>
						</div>
					<?php $counter++;?>
					<?php $price_total += $this->helper('tax')->getPrice($_product, $_product->getFinalPrice(), true);?>
					<?php endforeach?>
					</td>
					<td rowspan="2" class="promotion-info">
						<div class="main-info">
							<p><?php echo $this->__("Price For All Together");?>:<?php echo Mage::helper('core')->currency( $price_total - $bundled_promotion->getDiscount( $price_total )*$price_total/100,true,true);?></p>
							<p><?php echo $this->__("Save");?>&nbsp;<?php echo $bundled_promotion->getDiscount( $price_total );?>%:<?php echo Mage::helper('core')->currency( $bundled_promotion->getDiscount( $price_total )*$price_total/100,true,true);?></p>
						</div>
						<div class="actions">
							<button class="button" type="submit"><span><?php echo $this->__('Add all to cart');?></span></button>
						</div>
					</td>
				</tr>
				<tr><td>
					<?php $counter = 0;?>
					<?php foreach( $collection as $_product ):?>
						<div class="product-name <?php if( $counter + 1 == $collection->getSize() ) echo 'last'?>">
							<a class="link" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'thumbnail')) ?>">
								<?php echo $_product->getName();?>
							</a>
							<?php echo Mage::helper('core')->currency($this->helper('tax')->getPrice($_product, $_product->getFinalPrice(), true),true,true);?>
							<input type="hidden" name="products_id[<?php echo $_product->getId();?>]" value="1">
						</div>
					<?php $counter++;?>
					<?php endforeach?>
				</td></tr>
			</tbody>
		</table>
		<?php $promotion_counter++;?>
		<?php endforeach?>
	</div>
</div>
<?php endif?>
